package adventure.commands;

import adventure.*;
import player.*;

/**
 *
 * @author Michael Hanns
 *
 */
public class Emote extends AbstractCommand {

    public Emote(Adventure a) {
        super(a, new String[]{"EMOTE"});
    }

    @Override
    public String validateAndExecute(Player p, String[] args) {
        if (args.length == 1) {
            return "Emote what?";
        } else {
            String text = Util.consolidateArguments(args);

            if (Character.isLetterOrDigit(text.charAt(text.length() - 1))) {
                text += '.';
            }
            out.broadcastLocalToPlayer(p, p.getName() + " " + text);

            return p.getName() + " " + text;
        }
    }
}
